import * as React from "react";
import { DatePicker, List } from "antd-mobile";

const mode = {
  date: "date",
  datetime: "datetime",
  time: "time",
};
export default props => {
  console.log(props);
  const key = props["data-key"];
  const { node } = props;
  const timeFormat = node.data.get("timeFormat");
  const dateFormat = node.data.get("dateFormat");
  const labelText = node.data.get("label");
  let temp = mode.date;
  if (timeFormat && dateFormat) {
    temp = mode.datetime;
  } else if (timeFormat && !dateFormat) {
    temp = mode.time;
  }
  return (
    <DatePicker
      data-key={key} disabled
      mode={temp}
    >
      <List.Item arrow="horizontal">
        <span className="formitem">{labelText}</span>
      </List.Item>
    </DatePicker>
  );
};
